import request from '@/utils/request'

export const loginUser = (data) => {
  return request({
    url: '/sys/login',
    method: 'post',
    data
  })
}

export const getProfile = () => {
  return request({
    url: '/user/profile',
  })
}

export const registerUser = (data) => {
  return request({
    url: '/sys/register',
    method: 'post',
    data
  })
}

export const putProfile = (data) => {
  return request({
    url: '/user/profile',
    method: 'put',
    data
  })
}

export const getSts = () => {
  return request({
    url: '/user/sts',
  })
}

// 微信登录前置数据获取
export const getWXLoginData = () => {
  return request({
    url: '/sys/wxlogin/data',
  })
}

// 微信登录获取access_token
export const getWXAccessToken = (appid, secret, code) => {
  return request({
    url: '/sys/wxlogin/access_token',
    params: {
      appid,
      secret,
      code
    }
  })
}

// 微信登录获取用户信息
export const getWXLoginUserInfo = (accessToken, openid) => {
  return request({
    url: '/sys/wxlogin/userinfo',
    params: {
      accessToken,
      openid
    }
  })
}